import { axios } from "@/utils/request";

const api = {
  validateField: 'fieldRepeatCheck',
  files: 'mos-file/upload',
  tableFields: 'show-fields',
};

/**
 * 表单字段校验
 * @param { { string key, any value, [`create`| `update`] type, string url } } params 
 */
export function validateField(params) {
  return axios({
    url: api.validateField,
    method: 'get',
    params
  })
}

// 上传文件
export function uploadFile(params) {
  return axios({
    url: api.files,
    method: 'post',
    data: params
  })
}


/**
 * 表格字段显示
 */
export function readTableFields(params) {
  return axios({
    url: api.tableFields,
    method: 'get',
    params
  })
}

/**
 * 表格字段更新
 */
export function updateTableFields(data) {
  return axios({
    url: api.tableFields,
    method: 'put',
    data
  })
}